﻿var net = require('net'), tcp = require('../DataAccess/TCPClient.js');

var MOSERIP = '192.168.1.52',
MOLOGINPORT = 5231,
MOPORT = 5232;
exports.index = function () {
    this.render('Socket/index.html', { msg: 'Hello World' });
};

exports.data = function () {

};

MO = {
    Client: null,
    user: 'cjhs',
    session: '',
    Login: function () {
        var c = new tcp.TCPClient(MOSERIP, MOLOGINPORT,
        function () {
            client.send(2, MO.user + '#eee333#');
        },
        function (data) {
            data = data.content.split('#');
            MO.session = data[1];
            MO.Send(3, MO.session);
        });
    },
    Send: function (tid, content, context) {
        if (!MO.Client) {
            MO.Client = new tcp.TCPClient(MOSERIP, MOPORT,
                    function () {
                        MO.Client.send(tid, MO.user + '|' + content);
                    },
                    function (data) {
                        console.log(data);

                        Pro_cmd[4].call(context, data.content);
                    });
        } else {
            MO.Client.send(tid, MO.user + '|' + content);
        }
    }
};

Pro_cmd = {

    4: function (content) { }

};